package com.ying.sms;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@RabbitListener(queues = "sms")
public class SendSms {

    @Value("${api.send.appCode}")
    public String appCode;

    /**
     * 发送短信
     *
     * @param map
     */
    @RabbitHandler
    public void sendSms(Map<String, String> map){
        System.out.println("手机号:" + map.get("telephone"));
        System.out.println("验证码:" + map.get("verifyCode"));
        SendSmsApi.sendSms(appCode, map.get("telephone"), map.get("verifyCode"));
    }
}